/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.managed.burndown;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import smary.ejb.entity.Sprint;
import smary.ejb.entity.Task;
import smary.ejb.stateless.auto.SprintFacade;
import smary.managed.auto.SprintController;
import smary.managed.auto.TaskController;

/**
 * Managed Bean zur Bestimmung des Grafen des Burndownchart.
 * @author ACANPOWER
 */
@Named(value = "burndownChartService")
@RequestScoped
public class BurndownChartService {
    
    @EJB
    SprintController sc;
    
    @EJB
    TaskController tc;

    private Sprint currentSprint;

    public Sprint getCurrentSprint() {
        return currentSprint;
    }

    public void setCurrentSprint(Sprint currentSprint) {
        this.currentSprint = currentSprint;
    }
    /**
     * Creates a new instance of BurndownChartService
     */
    public BurndownChartService() {
    }
    
    public int getDayCount(){
        Date start = currentSprint.getSprintbeginn();
        Date end = currentSprint.getSprintende();
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.DAY_OF_MONTH,end.getDay());
        cal.set(Calendar.MONTH,end.getMonth());
        cal.set(Calendar.YEAR,end.getYear());
        
        return (int) ((cal.getTimeInMillis() - start.getTime())/(1000*60*60*24));
    }
    public int[] getTaskEffortsOfSprint(){
        List<Integer> returnList = new ArrayList<Integer>();
        for(Task tasks : currentSprint.getTasks()){
            returnList.add(tasks.getEffort());
        }
        return null;
    }
}
